﻿<Window x:Class="BillsWpf.PaymentReminder"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
        xmlns:sys="clr-namespace:System;assembly=System"
	xmlns:local="clr-namespace:BillsWpf"
    Title="Payment Reminder" Height="840" Width="961" xmlns:my="clr-namespace:BillsDomain;assembly=BillsDomain" Loaded="Window_Loaded" Closed="Window_Closed" DataContext="{Binding}" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
    <Window.Resources>
        <CollectionViewSource x:Key="paymentWithDateViewSource" d:DesignSource="{d:DesignInstance my:PaymentWithDate, CreateList=True}" />
        <CollectionViewSource x:Key="paymentViewSource" d:DesignSource="{d:DesignInstance my:Payment, CreateList=True}" />
        <CollectionViewSource x:Key="calendarDayViewSource" d:DesignSource="{d:DesignInstance my:CalendarDay, CreateList=True}" />
        <!--<local:WeightConverter x:Key="WeightConverter"/>-->
        <Style x:Key="BoldCalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}">
            <Setter Property="MinWidth" Value="5"/>
            <Setter Property="MinHeight" Value="5"/>
            <Setter Property="FontSize" Value="10"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <!--<Setter Property="FontWeight" Value="{Binding Converter={StaticResource WeightConverter}, Path=Date}" />-->
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type CalendarDayButton}">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0:0:0.1"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
                                            <DoubleAnimation Duration="0" To=".35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NormalText"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="SelectionStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Unselected"/>
                                    <VisualState x:Name="Selected">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To=".75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SelectedBackground"/>
                                            <ColorAnimation Duration="0" To="{DynamicResource {x:Static SystemColors.ControlLightLightColorKey}}" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalText"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="CalendarButtonFocusStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="CalendarButtonFocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="CalendarButtonUnfocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Collapsed</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ActiveStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Active"/>
                                    <VisualState x:Name="Inactive">
                                        <Storyboard>
                                            <ColorAnimation Duration="0" To="#FF777777" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalText"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="DayStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="RegularDay"/>
                                    <VisualState x:Name="Today">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="TodayBackground"/>
                                            <ColorAnimation Duration="0" To="{DynamicResource {x:Static SystemColors.ControlDarkDarkColorKey}}" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalText"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="BlackoutDayStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="NormalDay"/>
                                    <VisualState x:Name="BlackoutDay">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To=".2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Blackout"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Rectangle x:Name="TodayBackground" Fill="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" Opacity="0" RadiusY="1" RadiusX="1"/>
                            <Rectangle x:Name="SelectedBackground" Fill="{DynamicResource {x:Static SystemColors.MenuHighlightBrushKey}}" Opacity="0" RadiusY="1" RadiusX="1"/>
                            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
                            <Rectangle x:Name="HighlightBackground" Fill="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}" Opacity="0" RadiusY="1" RadiusX="1"/>
                            <ContentPresenter x:Name="NormalText" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="5,1,5,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                <TextElement.Foreground>
                                    <SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlDarkDarkColorKey}}"/>
                                </TextElement.Foreground>
                            </ContentPresenter>
                            <Path x:Name="Blackout" Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z" Fill="#FF000000" HorizontalAlignment="Stretch" Margin="3" Opacity="0" RenderTransformOrigin="0.5,0.5" Stretch="Fill" VerticalAlignment="Stretch"/>
                            <Rectangle x:Name="DayButtonFocusVisual" IsHitTestVisible="false" RadiusY="1" RadiusX="1" Stroke="#FF45D6FA" Visibility="Collapsed"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>

        <Grid>
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="SteelBlue" Offset="0" />
                <GradientStop Color="WhiteSmoke" Offset="1" />
            </LinearGradientBrush>
        </Grid.Background>
        <Button Height="23" Margin="12,12,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="75" Name="buttonAdd" Click="buttonAdd_Click">Add</Button>
        <DatePicker Height="25" HorizontalAlignment="Left" Margin="256,12,0,0" Name="datePickerAsOfDate" VerticalAlignment="Top" Width="115" SelectedDateChanged="datePickerAsOfDate_SelectedDateChanged" SelectedDate="1/1/1980"  />
        <Button Content="Edit" Height="23" HorizontalAlignment="Left" Margin="93,12,0,0" Name="buttonEdit" VerticalAlignment="Top" Width="75" Click="buttonEdit_Click" />
        <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" HorizontalAlignment="Left" ItemsSource="{Binding Source={StaticResource paymentWithDateViewSource}}" Margin="12,75,0,37" Name="upcomingPaymentDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Stretch" Width="400" IsReadOnly="True" DataContext="{Binding}" CanUserReorderColumns="False" CanUserSortColumns="False" IsManipulationEnabled="True" MouseDoubleClick="upcomingPaymentDataGrid_MouseDoubleClick" RowBackground="Aqua">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="dateColumn" Binding="{Binding Path=PaymentDate, StringFormat=\{0:d\}}" Header="Next Date" Width="Auto" />
                <DataGridTextColumn x:Name="payeeColumn" Binding="{Binding Path=Payee}" Header="Payee" Width="Auto"  />
                <DataGridTextColumn x:Name="amountColumn" Binding="{Binding Path=Amount, StringFormat=\{0:c\}}" Header="Amount" Width="Auto" />
                <DataGridTextColumn x:Name="balanceColumn" Binding="{Binding Path=Balance, StringFormat=\{0:c\}}" Header="Balance" Width="Auto" />
            </DataGrid.Columns>
        </DataGrid>
        <Calendar CalendarDayButtonStyle="{DynamicResource BoldCalendarDayButtonStyle}" Height="170" HorizontalAlignment="Left" Margin="418,75,0,0" Name="calendarItemsForADay" VerticalAlignment="Top" Width="180" SelectedDatesChanged="calendar1_SelectedDatesChanged" >
        </Calendar>
        <DataGrid AutoGenerateColumns="False" Height="200" Margin="604,75,72,0" Name="dataGrid1" VerticalAlignment="Top" ItemsSource="{Binding Source={StaticResource paymentViewSource}}" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserSortColumns="False" RowBackground="Aqua">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Path=Payee}" Header="Payee" Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=Amount, StringFormat=\{0:c\}}" Header="Amount" Width="Auto" />
            </DataGrid.Columns>
        </DataGrid>
        <d3:ChartPlotter x:Name="chartPlotterBalances" Margin="418,280,12,37" BorderBrush="White" Foreground="Black">
            <d3:ChartPlotter.Background>
                <RadialGradientBrush>
                    <GradientStop Color="AntiqueWhite" Offset="0" />
                    <GradientStop Color="SteelBlue" Offset="1" />
                </RadialGradientBrush>
            </d3:ChartPlotter.Background>
            <d3:ChartPlotter.MainHorizontalAxis>
                <d3:HorizontalDateTimeAxis Name="dateAxis" Foreground="White" Background="{x:Null}" MajorLabelBackgroundBrush="{x:Null}" AllowDrop="False" />
            </d3:ChartPlotter.MainHorizontalAxis>
            <d3:ChartPlotter.MainVerticalAxis>
                <d3:VerticalAxis Name="balanceAxis" Foreground="White" />
            </d3:ChartPlotter.MainVerticalAxis>
            <d3:LineGraph Name="balancesLineGraph">
                <d3:LineGraph.LinePen>
                    <Pen Thickness="3" Brush="DarkGoldenrod" />
                </d3:LineGraph.LinePen>
            </d3:LineGraph>
            <d3:Header FontFamily="Arial" Content="Balance 3 Months" Foreground="White" />
            <d3:VerticalAxisTitle FontFamily="Arial" Content="Balance" Foreground="White" />
            <d3:HorizontalAxisTitle FontFamily="Arial" Content="Date" Foreground="White" />

        </d3:ChartPlotter>
        <TextBox Height="23" HorizontalAlignment="Left" Margin="498,12,0,0" Name="textBoxCurrentBalance" VerticalAlignment="Top" Width="120" Text="0.00" TextChanged="textBoxCurrentBalance_TextChanged" />
        <DatePicker Height="25" HorizontalAlignment="Left" Margin="498,41,0,0" Name="datePickerDateForProjection" VerticalAlignment="Top" Width="115" SelectedDateChanged="datePickerDateForProjection_SelectedDateChanged" />
        <Label Height="28" HorizontalAlignment="Left" Margin="721,41,0,0" Name="labelProjectedBalance" VerticalAlignment="Top" />
        <Button Content="Delete" Height="23" HorizontalAlignment="Left" Margin="174,12,0,0" Name="buttonDelete" VerticalAlignment="Top" Width="75" Click="buttonDelete_Click" />
        <Label Content="Projected Balance" Height="28" HorizontalAlignment="Left" Margin="619,41,0,0" Name="labelProjectedBalanceLabel" VerticalAlignment="Top" />
        <Label Content="Current Balance" Height="28" HorizontalAlignment="Left" Margin="405,12,0,0" Name="labelCurrentBalanceLabel" VerticalAlignment="Top" />
    </Grid>
</Window>
